package com.gdut.huayan.dao;

import com.gdut.huayan.entity.po.LimitMoney;
import com.gdut.huayan.entity.po.Stock;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gdut.huayan.entity.vo.RefundDetailVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface StockMapper extends BaseMapper<Stock> {

    @Select("SELECT * FROM `t_limit_money` WHERE `id` IN(SELECT `limit_money_id` FROM `t_money_stock` WHERE `stock_id`=#{stockId})")
    List<LimitMoney> getLimitMoney(Long stockId);

    @Select("SELECT  s.`id` stockId, " +
            "s.`remark` stockRemark, " +
            "r.`id` refundDetailId, " +
            "od.`id` orderDetailId" +
            "" +
            "FROM `t_refund_detail` r LEFT JOIN `t_order_detail` od ON r.`order_detail_id` = od.`id` LEFT JOIN `t_stock` s ON od.`stock_id` = s.`id` WHERE r.`refund_id` = #{param1}")
    List<RefundDetailVo> selectStockByRefund(Long refundId);
}
